home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode New for 1.6 / WorldRayPickSample / Source / WRay_Message.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-20  |  3.2 KB  |  166 lines  |  [TEXT/CWIE]

  1. /* 
  2.  *    WRay_Message.c
  3.  *
  4.  *    QuickDraw 3D 1.6 Sample
  5.  *    Robert Dierkes
  6.  *
  7.  *     07/28/98    RDD        Created.
  8.  */
  9.  
  10. /*------------------*/
  11. /*    Include Files    */
  12. /*------------------*/
  13. #include "QD3D.h"
  14. #include "QD3DErrors.h"
  15. #include <string.h>
  16.  
  17.  
  18. #ifdef USE_DEBUGGING
  19.     #define    LIBRARY_ERROR    0    /**/
  20.     #define    SECRET_ERROR    1    /**/
  21. #endif /* USE_DEBUGGING */
  22.  
  23. /*------------------*/
  24. /*    Include Files    */
  25. /*------------------*/
  26. #if    defined(LIBRARY_ERROR) && (LIBRARY_ERROR)
  27. #include "Error_Lib.h"
  28. #endif /* LIBRARY_ERROR */
  29.  
  30. #include "WRay_Message.h"
  31.  
  32.  
  33. #if    defined(SECRET_ERROR) && (SECRET_ERROR)
  34.  
  35. /*----------------------*/
  36. /*    Local Prototypes    */
  37. /*----------------------*/
  38. static void Message_Concatenate(
  39.     char    *typeStr,
  40.     long    value,
  41.     char    *message,
  42.     char    *outputMessage);
  43.  
  44. static void Message_SecretError(
  45.     TQ3Error    error,
  46.     char        *message);
  47.  
  48. static void Message_SecretNotice (
  49.     TQ3Notice    notice,
  50.     char        *message);
  51.  
  52. static void Message_SecretWarning(
  53.     TQ3Warning    warning,
  54.     char        *message);
  55.  
  56.  
  57. typedef void (*EtDevelopmentErrorFunc)(
  58.     TQ3Error        error,
  59.     char         *message);
  60.  
  61. void EiDevelopmentError_Register(
  62.     EtDevelopmentErrorFunc        errorFunc);
  63.  
  64. typedef void (*EtDevelopmentNoticeFunc)(
  65.     TQ3Notice    notice,
  66.     char         *message);
  67.  
  68. void EiDevelopmentNotice_Register(
  69.     EtDevelopmentNoticeFunc        noticeFunc);
  70.  
  71. typedef void (*EtDevelopmentWarningFunc)(
  72.     TQ3Warning    warning,
  73.     char         *message);
  74.  
  75. void EiDevelopmentWarning_Register(
  76.     EtDevelopmentWarningFunc    warningFunc);
  77.  
  78. #endif /* SECRET_ERROR */
  79.  
  80.  
  81.  
  82. void Message_Register(void)
  83. {
  84. #if    defined(LIBRARY_ERROR) && (LIBRARY_ERROR)
  85.     InstallDefaultErrorHandler();
  86.     InstallDefaultWarningHandler();
  87.     InstallDefaultNoticeHandler();
  88. #endif /* LIBRARY_ERROR */
  89.  
  90.  
  91. #if    defined(SECRET_ERROR) && (SECRET_ERROR)
  92.  
  93.     EiDevelopmentError_Register  (NULL);
  94.     EiDevelopmentNotice_Register (NULL);
  95.     EiDevelopmentWarning_Register(NULL);
  96.  
  97.     EiDevelopmentError_Register  (Message_SecretError);
  98.     EiDevelopmentNotice_Register (Message_SecretNotice);
  99.     EiDevelopmentWarning_Register(Message_SecretWarning);
  100.  
  101. #endif /* SECRET_ERROR */
  102. }
  103.  
  104.  
  105. #if    defined(SECRET_ERROR) && (SECRET_ERROR)
  106.  
  107. static void Message_Concatenate(char *typeStr, long value, char *message, char *outputMessage)
  108. {
  109.     char    *slash, *period, *start;
  110.  
  111.     start = message;
  112.  
  113.     /* Find first period in file name at end of path name */
  114.     period = strchr(message, '.');
  115.     if (period != NULL) {
  116.         *period = '\0';
  117.  
  118.         /* Find last slash in path name */
  119.         slash = strrchr(message, '/');
  120.         if (slash != NULL) {
  121.             /* No path name */
  122.             start = slash+1;
  123.         }
  124.  
  125.         *period = '.';
  126.     }
  127.  
  128.     sprintf (outputMessage, "QD3D %s %ld: %s", typeStr, value, start);
  129. }
  130.  
  131. static void Message_SecretError(TQ3Error error, char *message)
  132. {
  133.     char    outputMessage[512];
  134.  
  135.     Message_Concatenate("Error", error, message, outputMessage);
  136.  
  137. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  138.     debugstr(outputMessage);
  139. #endif
  140. }
  141.  
  142. static void Message_SecretNotice(TQ3Notice notice, char *message)
  143. {
  144.     char    outputMessage[512];
  145.  
  146.     Message_Concatenate("Notice", notice, message, outputMessage);
  147.  
  148. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  149.     debugstr(outputMessage);
  150. #endif
  151. }
  152.  
  153. static void Message_SecretWarning(TQ3Warning warning, char *message)
  154. {
  155.     char    outputMessage[512];
  156.  
  157.     Message_Concatenate("Warning", warning, message, outputMessage);
  158.  
  159. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  160.     debugstr(outputMessage);
  161. #endif
  162. }
  163.  
  164. #endif /* SECRET_ERROR */
  165.  
  166.